package com.yun.algorithmproblem.leetcode;

import java.util.ArrayList;
import java.util.List;

public class Leetcode119 {

    public static void main(String[] args) {
        Leetcode119 obj = new Leetcode119();
        System.out.println(obj.getRow(30));
    }

    public List<Integer> getRow(int rowIndex) {
        List<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 1; i <= rowIndex / 2; i++) {
            Integer prev = list.get(i - 1);
            long curr= ((long) prev *(rowIndex-i+1)/i);
            list.add((int) curr);
        }
        for (int i = rowIndex / 2 + 1; i <= rowIndex; i++) {
            if (rowIndex / i == 2) {
                continue;
            }
            list.add(list.get(rowIndex - i));
        }
        return list;
    }
}
